import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

/**
 * Description:
 * Date: 2025-11-09
 * Time: 15:04
 */
public class Test {
    public static void main1(String[] args) {
        MyLinkedList list = new MyLinkedList();
        list.addLast(2);
        list.addLast(2);
        list.addLast(2);
        list.addLast(2);
        list.addLast(2);
        list.display();
        list.clear();
        list.display();


//        list.addFirst(99);
//        list.display();
//        list.addLast(9);
//        list.display();

        /*list.addIndex(0,99);
        list.display();
        list.addIndex(list.size(), 9);
        list.display();
        System.out.println(list.contains(-1));*/

        /*list.remove(2);
        list.display();
        list.removeAllKey(2);
        list.display();*/

    }

    public static void main(String[] args) {
        List<Integer> linkedList = new LinkedList<>();
        linkedList.add(12);//默认尾插法
        linkedList.add(23);
        linkedList.add(34);
        linkedList.add(45);

        System.out.println("for循环打印");
        for (int i = 0; i < linkedList.size(); i++) {
            System.out.print(linkedList.get(i) + " ");
        }
        System.out.println();

        System.out.println("for each 循环打印");
        for (Integer x : linkedList) {
            System.out.print(x + " ");
        }
        System.out.println();

        System.out.println("Iterator迭代器打印");
        Iterator<Integer> it =  linkedList.iterator();
        while (it.hasNext()) {
            System.out.print(it.next() + " ");
        }
        System.out.println();
    }
}
